/*
 * queue_example.cpp
 *
 *  Created on: 2 sept. 2014
 *      Author: marioc
 */

// cont/queue1.cpp
#include <iostream>
#include <queue>
#include <string>
#include <stdlib.h>

#include <algostuff.h>

using namespace std;

int min_max_example();

int main()
{

    queue<string> q;

    // insert three elements into the queue
    q.push("These ");
    q.push("are ");
    q.push("more than ");

    // read and print two elements from the queue
    cout << q.front();
    q.pop();
    cout << q.front();
    q.pop();

    // insert two new elements
    q.push("four ");
    q.push("words!");
    // skip one element
    q.pop();

    // read and print two elements
    cout << q.front();
    q.pop();
    cout << q.front() << endl;
    q.pop();

    //print number of elements in the queue
    cout << "number of elements in the queue: " << q.size() << endl;

	priority_queue<float> qprio;

	// insert three elements into the priority queue
	qprio.push(66.6);
	qprio.push(22.2);
	qprio.push(44.4);

	// read and print two elements
	cout << qprio.top() << ' ';
	qprio.pop();
	cout << qprio.top() << endl;
	qprio.pop();

	// insert three more elements
	qprio.push(11.1);
	qprio.push(55.5);
	qprio.push(33.3);

	// skip one element
	qprio.pop();


	//pop and print remaining elements
	while (!qprio.empty()) {
		cout << qprio.top() << ' ';
		qprio.pop();
	}
	cout << endl;


	min_max_example();
}


bool absLess (int elem1, int elem2)
{

    return abs(elem1) < abs (elem2);
}


int min_max_example()
{
    deque<int> coll;

    INSERT_ELEMENTS(coll,2,8);
    INSERT_ELEMENTS(coll,-3,5);

    PRINT_ELEMENTS(coll);

    // process and print minimum and maximum
    cout << "minimum: " << *min_element(coll.begin(),coll.end()) << endl;
    cout << "maximum: " << *max_element(coll.begin(),coll.end()) << endl;

    // process and print minimum and maximum of absolute values
    cout << "minimum of absolute values: " << *min_element(coll.begin(),coll.end(), absLess) << endl;
    cout << "maximum of absolute values: " << *max_element(coll.begin(),coll.end(), absLess) << endl;

    return 0;
}
